<?php

/*
 * to change this template, choose tools | templates
 * and open the template in the editor.
 */

/**
 * description of upload
 *
 * @author montecristo
 */
class upload extends ci_controller {

    function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
        $this->load->model("encuestas_model","modal");
    }

    function index() {
      //  $this->load->view('upload_form', array('error' => ' '));
    }

    function do_upload() {
        $session_data = $this->session->userdata('logged_in'); 
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '200';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $config['overwrite'] = true;
        $config['file_name'] ='logo-'.$session_data["empresa"].'.jpg';
                 $this->load->library('upload', $config);
        if (!$this->upload->do_upload()) {
            $error = array('error' => $this->upload->display_errors());
            $this->modal->insertconfiguracion($session_data['empresa'],$this->input->post('campos'),$config['file_name'],0);
            redirect('home');
        } else {
             $data = array('upload_data' => $this->upload->data());             
             $this->modal->insertconfiguracion($session_data['empresa'],$this->input->post('campos'),$config['file_name'],1);
             redirect('home');
        }
    }
    
    public function configuracion(){
        $session_data = $this->session->userdata('logged_in'); 
        $result=$this->modal->getconfiguracioninfo($session_data['empresa']);       
        echo json_encode($result);
    }

}

?>
